* Author: Anina Schwarzenbach
* generated October 2014
* last review August 2020

clear
*cd: 
use "../../STATAfiles/S11DE_version4.dta"
set more off

*load ADOS
sysdir set PERSONAL "../../../ados"

*******************************************************************************************
*SCAELS FOR GERMANY
******************************************************************************************

*define labels
label define dummylb 0 "no" 1 "yes", replace 
label define scalelb 1 "not true at all" 4 "completely true", replace

******** ******** ******** ******** ******** ******** 
*COMMITMENT TO SCHOOL 
foreach v of var attsch1 attsch2 attsch3 attsch4 { 
	recode `v' (4=1) (3=2) (2=3) (1=4), gen (`v'f)
}

global polyitems  attsch1f attsch2f attsch3f
fre $polyitems
egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 2
				replace polypca`var'=. if polyvalid < 2
				*fre polypca`var'				

}

polychoric polypca* /*polychoric correlation matrix*/
display r(sum_w) /*n of cases*/
global N = r(sum_w) /*global macro n of cases*/
matrix r = r(R) /*matrix object*/
factormat r, pf n($N) factors(1) /*factor analysis unidimensional w/o rotation*/
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash))
alpha polypca* // 0.5684

predict  sattsch 
egen zsattsch = std(sattsch) 
drop poly* 	

label var zsattsch "score positive school attitude (higher=better)"

*** GERMANY
global polyitems  attsch1f attsch2f attsch3f 
*global polyitems  attsch1f attsch2f attsch3f attsch4f
fre $polyitems

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 2
				replace polypca`var'=. if polyvalid < 2
}

polychoric polypca* 
display r(sum_w) 
global N = r(sum_w) 
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash))
alpha polypca* //0.5684

predict  sattschDE 
egen zsattschDE = std(sattschDE) 
drop poly* 	

label var zsattschDE "score positive school attitude (higher=better) - GERMANY"

******** ******** ******** ******** ******** ******** 
*ATTACHMENT TO MOTHER 
*** GERMANY
global polyitems attmtr1f attmtr2f attmtr3 attmtr4 attmtr5f attmtr6

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 5
				replace polypca`var'=. if polyvalid < 5
}

polychoric polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 
alpha polypca* //0.7507

predict  sattmtrDE
egen zsattmtrDE = std(sattmtrDE) 
drop poly* 	

label var zsattmtrDE "score attitudes toward mother (higher=better)"

******** ******** ******** ******** ******** ******** 
*PARENTAL MONITORING

/*
global polyitems parmon1 parmon2

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid == 2
				replace polypca`var'=. if polyvalid < 2
}

polychoric polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 

predict  sparmon
egen zsparmon = std(sparmon) 
drop poly* 	

label var zsparmon "score parental monitoring / information parents about leisure time / peers (higher=better)"
*/

*** GERMANY
global polyitems parmon1 parmon2 parmon3

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 2
				replace polypca`var'=. if polyvalid < 2
}

polychoric polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 
alpha polypca* // 0.7975

predict  sparmonDE
egen zsparmonDE = std(sparmonDE) 
drop poly* 	

label var zsparmonDE "score parental monitoring / information parents about leisure time / peers (higher=better) - GERMANY"

******** ******** ******** ******** ******** ******** 
* NEGIHBORHOOD PERCEPTIONS
* overview distribution missings
fre nbhd2 nbhd3 nbhd4 nbhd5 nbhd6 if xmod==1

* all variables
foreach v in nbhd2 nbhd3 nbhd4 nbhd5 nbhd6 {
	recode `v' (99=.)
}

global polyitems nbhd2 nbhd3 nbhd4 nbhd5 nbhd6 

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 3
				replace polypca`var'=. if polyvalid < 3
}

polychoric polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 
alpha polypca* //0.8084

predict snbhd1 /*estimation of score*/ 
egen zsnbhd1 = std(snbhd1) /*z-transform*/
drop poly* /*drop temporary variables*/

*neighbourhood incivilities
global polyitems nbhd4 nbhd5 nbhd6

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid == 3
				replace polypca`var'=. if polyvalid < 3
}


polychoric polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 
alpha polypca* //0.7129

predict snbhd2  
egen zsnbhd2 = std(snbhd2) 
drop poly* 

label var zsnbhd1 "score neighbourh. perception  (higher=worse)" 
label var zsnbhd2 "score neighbourh. incidvilities  (higher=worse)"

******** ******** ******** ******** ******** ******** 
* DEVIANT ATTITUDES

**NEW
foreach v of var attviol1 attviol3 attviol5 {
	recode `v' (4=1) (3=2) (2=3) (1=4), gen (`v'f)
}

global polyitems  attviol1f attviol2 attviol4 attviol5f

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 3
				replace polypca`var' =. if polyvalid < 3				
}

polychoric polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 
alpha polypca* //0.6162

predict sattviol 
egen zsattviol = std(sattviol) 
drop poly* 

label var zsattviol "score deviant attitudes (higher=more)"
label define zsattviollb 1 "low" 4 "high"
label val zsattviol zsattviollb


*** GERMANY

*NEW
global polyitems  attviol1f attviol2 attviol3f attviol4 attviol5f

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 4
				replace polypca`var' =. if polyvalid < 4
}

polychoric polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 
alpha polypca* //0.7146

predict sattviolDE 
egen zsattviolDE = std(sattviolDE) 
drop poly* 

label var zsattviolDE "score deviant attitudes (higher=more) - GERMANY"


******** ******** ******** ******** ******** ******** 
* DELINQUENCY OF PEERS
*egen speerdel=rowmean(peerdel2 peerdel5 peerdel6 peerdel7)
*capture drop speerdel

global polyitems  peerdel2 peerdel5 peerdel6 peerdel7
fre $polyitems

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 3
				replace polypca`var'=. if polyvalid < 3
}

polychoric polypca* /*polychoric correlation matrix*/
display r(sum_w) /*n of cases*/
global N = r(sum_w) /*global macro n of cases*/
matrix r = r(R) /*matrix object*/
factormat r, pf n($N) factors(1) /*factor analysis unidimensional w/o rotation*/
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash))
alpha polypca* // 0.7186

predict speerdel 
egen zspeerdel = std(speerdel) 
drop poly* 


*** GERMANY 
global polyitems  peerdel1 peerdel2 peerdel3 peerdel4 peerdel5 peerdel6 peerdel7 peerdel8 peerdel9
fre $polyitems

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 5
				replace polypca`var'=. if polyvalid < 5
}

polychoric polypca* /*polychoric correlation matrix*/
display r(sum_w) /*n of cases*/
global N = r(sum_w) /*global macro n of cases*/
matrix r = r(R) /*matrix object*/
factormat r, pf n($N) factors(1) /*factor analysis unidimensional w/o rotation*/
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash))
alpha polypca* // 0.8267


predict speerdelDE 
egen zspeerdelDE = std(speerdelDE) 
drop poly* 

******** ******** ******** ******** ******** ******** 
* POLICE LEGITIMACY

capture drop splegr spleg_fair splegr_fair zspleg_fair zspleg_moral spleg_moral splegr_moral

foreach v of var pleg2 pleg5 pleg6 pleg7 {
	recode `v' (4=1) (3=2) (2=3) (1=4), gen(`v'f)
	recode `v'f (99=.)
}

*general
***all items EXCEPT pleg5f 
global polyitems pleg1 pleg2f pleg3 pleg4 pleg6f pleg7f 
fre $polyitems 

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 5
				replace polypca`var' =. if polyvalid < 5				
}


polychoric polypca* 
*alpha polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 
alpha polypca* // 0.7847

predict spleg  
egen zspleg = std(spleg) 
drop poly* 

lab var zspleg "score police legitimacy (higher=better)"

corr zspleg age3
spearman zspleg dole1

/*
* fairness 
pleg1: The police protect adolescents
pleg2f: The police disrespect adolescents
pleg3: Overall the police can be trusted
pleg7f: The police treat foreigners worse than native people

*obligation to obey
pleg4: One should in any case follow the instructions of the police
pleg6f: If adolescents protest violently and with riots against the police I would join them
pleg5f: Even if having a serious problem, I would never contact the police

*/


* fairness 
global polyitems pleg1 pleg2f pleg3 pleg7f 
fre $polyitems 

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid


foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 3
				replace polypca`var' =. if polyvalid < 3				
}


polychoric polypca* 
*alpha polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 
alpha polypca* // alpha=0.73

predict spleg_fair 
egen zspleg_fair = std(spleg_fair) 
drop poly* 

lab var zspleg_fair "score police legitimacy (higher=better) - FAIRNESS"

*obligation to obey

*AS MEAN VALUE ???

recode pleg4  (99=.)
recode  pleg5f (99=.)
fre pleg4 pleg5f 

alpha pleg4 pleg5f 

egen spleg_obey=rowmean(pleg4 pleg5f)
lab var spleg_obey "mean police legitimacy (higher=better) -  OBLIGATION TO OBEY"

egen zspleg_obey = std(spleg_obey) 

/*
global polyitems  pleg4 pleg5f pleg6f 
fre $polyitems 

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 2
				replace polypca`var' =. if polyvalid < 2				
}


polychoric polypca* 
*alpha polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 
alpha polypca* // 0.5475

predict spleg_obey  
egen zspleg_obey = std(spleg_obey) 
drop poly* 

lab var zspleg_obey "score police legitimacy (higher=better) -  OBLIGATION TO OBEY"
*/

******** ******** ******** ******** ******** ******** 
* POLICE BEHAVIOR
*drop pbeh1f pbeh2f spbeh

foreach v in pbeh1 pbeh2 {
	recode `v'(4=1) (3=2) (2=3) (1=4), gen (`v'f)
	*label define pbehlb 1 "no, not true at all" 2 "no, rather untrue" 3 "yes, rather true" 4 "yes, fully true", replace
	*label value `v'f pbehlb
}

global polyitems  pbeh1f pbeh2f pbeh3 pbeh4
*global polyitems   pbeh2f pbeh3 pbeh4

fre $polyitems if xmod==1 & lastcont3 > 0 & lastcont3 !=99

alpha $polyitems
egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 3
				replace polypca`var' =. if polyvalid < 3				
}


polychoric polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash))  
alpha polypca* //0.5894

predict spbeh 
egen zspbeh = std(spbeh) 
drop poly* 

label var zspbeh "score police behavior 1-4 (higher=better)"

******************************** SCALES FOR GERMANY ONLY  ********************************

******** ******** ******** ******** ******** ******** 
*LEISURE TIME ACTIVITIES

*fun / action 
***without item activ8 after analysis of factors includig all items !!!
global polyitems activ9 activ10 activ11 
*global polyitems  activ8 activ9 activ10 activ11 
fre $polyitems 

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 2
				replace polypca`var' =. if polyvalid < 2				
}


polychoric polypca* 
*alpha polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 
alpha polypca* // 0.7197

predict sactiv1DE  
egen zsactiv1DE = std(sactiv1DE) 
drop poly* 

lab var zsactiv1DE "score leisure time activity - FUN / ACTION  (higher=better)"

/*
*cultural / youth association
global polyitems  activ1 activ2 activ12 
*global polyitems  activ1 activ2 activ3 activ6 activ7 activ12 
fre $polyitems 

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 2
				replace polypca`var' =. if polyvalid < 2				
}


polychoric polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 
alpha polypca*

predict sactiv2DE  
egen zsactiv2DE = std(sactiv2DE) 
drop poly* 

lab var zsactiv2DE "score leisure time activity - CULTURAL / YOUTH ASSOCIATION  (higher=better)"

*sports
global polyitems  activ4 activ5  
fre $polyitems 

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 2
				replace polypca`var' =. if polyvalid < 2				
}


polychoric polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 
alpha polypca*

predict sactiv3DE  
egen zsactiv3DE = std(sactiv3DE) 
drop poly* 

lab var zsactiv3DE "score leisure time activity - SPORTS  (higher=better)"
*/

******** ******** ******** ******** ******** ******** 
*SELF-CONTROL
global polyitems  m1_1f m1_2f m1_3f m1_4f m1_5f    
fre $polyitems 

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 3
				replace polypca`var' =. if polyvalid < 3				
}


polychoric polypca* 
*alpha polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 
alpha polypca* // 0.7619

predict selfcont  
egen zselfcont = std(selfcont) 
drop poly* 

lab var zselfcont "score self-control (higher=better)"

******** ******** ******** ******** ******** ******** 
*SZENARIOS
*(as mean values!!)


* szenario call parents /school / police 
global polyitems  d6_1f d7_1f d6_2f d7_2f d7_3f
fre $polyitems 

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid >= 3
				replace polypca`var' =. if polyvalid < 3				
}


polychoric polypca* 
*alpha polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 
alpha polypca* // 0.8273

predict szenario1  
egen zszenario1 = std(szenario1) 
drop poly* 

lab var zszenario1 "szenario call parents / school / police"

* szenario call police 
fre d6_2f d7_3f

egen szenario2=rowmean(d6_2f d7_3f)
lab var szenario2 "szenario call police"

*check
corr sd67b szenario2
fre szenario2

/*
global polyitems  d6_2f d7_3f
fre $polyitems 

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid == 1
				replace polypca`var' =. if polyvalid < 1				
}


polychoric polypca* 
*alpha polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 
alpha polypca*

predict szenario2  
egen zszenario2 = std(szenario2) 
drop poly* 
*/

* szenario self-justice 
fre d6_3f d7_4f
egen szenario3=rowmean(d6_3f d7_4f)
lab var szenario3 "szenario self-justice"
fre szenario3

*check
corr sd67c szenario3

/*
global polyitems  d6_3f d7_4f
fre $polyitems 

egen polyvalid = anycount ($polyitems), values (1/4) /*count nonmissing*/
fre polyvalid

foreach var in $polyitems{
                gen polypca`var' = `var' 
                quietly sum `var', detail
                replace polypca`var' = r(p50) if `var' ==. & polyvalid == 1
				replace polypca`var' =. if polyvalid < 1				
}


polychoric polypca* 
*alpha polypca* 
display r(sum_w) 
global N = r(sum_w)
matrix r = r(R) 
factormat r, pf n($N) factors(1) 
*screeplot, mean meanlopts(lwidth(thin) lpattern(dash)) 
alpha polypca*

predict szenario3  
egen zszenario3 = std(szenario3) 
drop poly* 
*/





********************
*
********************

******************************** STANDARDIZATION OF SCALES (NON-FACTORS)  ********************************
* rescaling variable to the max = 4
quietly sum spleg
gen splegbeta = spleg*(10/r(max))
sum splegbeta

quietly sum splegbeta
gen splegbeta2 = splegbeta*(1/r(min))
sum splegbeta2

quietly sum spleg
gen splegbeta3 = spleg*(1/r(min))
sum splegbeta3

quietly sum splegbeta3
gen splegbeta4 = splegbeta3+(10/4)
sum splegbeta4



quietly sum spleg
gen splegr = spleg*(4/r(max))
sum splegr

quietly sum spleg_fair
gen splegr_fair = spleg_fair*(4/r(max))
sum splegr_fair

quietly sum spleg_obey
gen splegr_obeyr = spleg_obey*(4/r(max))
sum splegr_obeyr 


quietly sum sattviol
gen sattviolr = sattviol*(4/r(max))
sum sattviolr

quietly sum szenario1
gen szenario1r= szenario1*(4/r(max))
sum szenario1r

quietly sum szenario2
gen szenario2r= szenario2*(4/r(max))
sum szenario2r

quietly sum szenario3
gen szenario3r= szenario3*(4/r(max))
sum szenario3r

quietly sum spbeh
gen spbehr = spbeh*(4/r(max))
sum spbehr

quietly sum svicexp
gen svicexpr = svicexp*(4/r(max))
sum svicexpr

*soci-demographics
quietly egen zage1 = std(age1)
egen za2ager = std(a2ager)
egen zISEIhigh = std(ISEIhigh)

*victimization
egen zvic_sum = std(vic_sum)

egen zd5an = std(d5an)
egen zd5bn = std(d5bn)
egen zd5cn = std(d5cn)

*delinquency
egen zsrd_sum = std(srd_sum)

egen zd4an = std(d4an)
egen zd4bn = std(d4bn)
egen zd4b2n = std(d4b2n)
egen zd4cn = std(d4cn)
egen zd4dn = std(d4dn)
egen zd4en = std(d4en)
egen zd4fn = std(d4fn)

* peer delinquency
egen zpeerdel_sum = std(peerdel_sum)
*egen zspeerdel = std(speerdel) 
*egen zspeerdelDE = std(speerdelDE) 

*police contact
egen zpcont_sum= std(pcont_sum)
egen zpconta_sum= std(pconta_sum)
egen zpcontb_sum= std(pcontb_sum)
egen zpcontc_sum= std(pcontc_sum)

egen zsc3as =std(sc3as)
egen zsc3bs = std(sc3bs)
egen zsc3cs = std(sc3cs)
egen zsc3ds = std(sc3ds)

*religious commitment
egen zrelig1 = std(relig1)
egen zm2 = std(m2)

*national identity
egen znatident1 = std(natident1)
egen znatident2 = std(natident2)

*police legitimacy - also as polychoric scale
egen zsc1a = std(sc1a)

*attachment to parents - also as polychoric scale
egen zse2ma = std(se2ma)
egen zse2va = std(se2va)

*parental monitoring
egen zsparmon = std(sparmon) 

*commitent to school - also as polychoric scale
egen zss9a = std(ss9a)
egen zse2b = std(se2b)
egen zse2c = std(se2c)

* attidues favourable to delinquency
egen zsd8a = std(sd8a)
egen zsd8b = std(sd8b)

* parental monitoring
egen zse1 = std(se1)

*police disrespect
egen zsc2k = std(sc2k)

*leisure time
egen zsp10a = std(sp10a)
egen zsp10b = std(sp10b)
egen zsp10c = std(sp10c)

*self-control
egen zsm1 = std(sm1)

*vicarous experiences
egen zsvicexp = std(svicexp)

*szenarios
egen zsd67a = std(sd67a)
egen zsd67b = std(sd67b)
egen zsd67c = std(sd67c)


*save
saveold "../../STATAfiles/S11DE_version4scales.dta", replace







